package cn.tedu.micro.demo.client;

import com.rabbitmq.client.*;
import com.rabbitmq.client.ConnectionFactory;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class RabbitChannelManager {
    public static Channel newChannel() {
        try{
            ConnectionFactory factory = new ConnectionFactory();
            factory.setHost("192.168.8.100");
            factory.setPort(5672);
            factory.setUsername("admin");
            factory.setPassword("123456");
            return factory.newConnection().createChannel();
        }catch(Exception e){
            log.error("创建连接失败", e);
            throw new RuntimeException(e);
        }
    }
}
